package pictogram.front;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;


public class RightFragment extends Fragment {
	
	private ImageButton buttonOk;
	private ImageButton buttonCancel;
	private ImageButton buttonTurn;
	
	private OnItemSelectedListener listener;
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		View view = inflater.inflate(R.layout.right_fragment, container, false);
		
		buttonOk = (ImageButton)view.findViewById(R.id.bOk);
		buttonOk.setOnClickListener(new View.OnClickListener() {	
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				buttonSelected("Ok");
			}
		});
		
		buttonCancel = (ImageButton)view.findViewById(R.id.bCancel);
		buttonCancel.setOnClickListener(new View.OnClickListener() {	
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				buttonSelected("Cancel");
			}
		});
		
		buttonTurn = (ImageButton)view.findViewById(R.id.bTurn);
		buttonTurn.setOnClickListener(new View.OnClickListener() {	
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				buttonSelected("Turn");
			}
		});
		
		return view;
		
	}
	
	public void buttonSelected(String bs)
	{
		listener.onButtonSelected(bs);
	}
	
	public interface OnItemSelectedListener
	{
		public void onButtonSelected(String option);
	}
	
	public void onAttach(Activity activity) {
	      super.onAttach(activity);
	      if (activity instanceof OnItemSelectedListener) {
	        listener = (OnItemSelectedListener) activity;
	      } else {
	        throw new ClassCastException(activity.toString()
	            + " must implemenet MyListFragment.OnItemSelectedListener");
	      }
	    }

}

